import React, { Component } from 'react';
class header extends Component {

  state = { 
    title:'',//联系人
    count:'',//评论内容
   }


  // 评论人
  pinlun =(e)=>{
    this.setState({
      title:e.target.value
    })
  }

  // 评论人
  neirong = (e) => {
    this.setState({
      count: e.target.value
    })
  }

  // 发表
  fabiao =()=>{
    let {title,count} = this.state
    this.props.updateList({title,count})
    this.setState({ //发表之后清空内容
      title:'',
      count:""
    })
  }



  render() { 
    return ( 
      <>
        <div className=''>
          {/* 输入评论人 */}
          <div className='inpu'>
            <input className='inpu1' type="text" value={this.state.title} onChange={this.pinlun} placeholder='请输入评论人' />
          </div>

          {/* 评论内容 */}
          <div className=''>
            <textarea cols="50" rows="10" value={this.state.count} onChange={this.neirong} placeholder='请输入评论内容' />
          </div>

          {/* 发表评论 */}
          <button onClick={this.fabiao}>发表评论</button>
        </div>
      </>
     );
  }
}
 
export default header;